/*
 * Saphre - Suffix Arrays for Phrase Extraction
 * Copyright (C) 2013 
 * Dale Gerdemann - Tübingen, Germany 
 * Niko Schenk - Frankfurt am Main, Germany
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package saphre.commands;

import saphre.concordance.ConcordanceOverlap;
import saphre.core.Store;
import saphre.core.SuffixArray;
import util.Interval;

/**
 *
 * @author Dale Gerdemann
 */
public class CmdShowAlpha {

    SuffixArray pa;

    public void showAlpha(Store store,
            SuffixArray sa, SuffixArray pa, Interval top,
            ConcordanceOverlap concordOver) {
        if (pa == null) {
            pa = sa.prefixArray();
            this.pa = pa;
        }
        int[] unit = new int[1];
        for (String s : store.sigma()) {
            if (!s.matches("\\p{L}*")) {
            }
            unit[0] = store.wordToInt(s);
            Interval found2 = sa.search(unit, top);
            int lcp2 = sa.getLcp(found2);
            int tf = found2.tf();
            if (tf > 1) {
                concordOver.setTarget(s);
                concordOver.setTargetArray(unit);
                concordOver.traverse(found2, lcp2 - 1, pa, lcp2, sa);
            }
        }
    }
}
